package
{

	import com.vzaar.Vzaar;
	import com.vzaar.VzaarEvent;

	import flash.display.Sprite;
	import flash.system.Security;
	import flash.text.TextField;

	public class WhoAmI extends Sprite
	{
		public function WhoAmI()
		{
			super();

			trace("init");

			var txt:TextField = new TextField();
			txt.text = 'Loading...';
			this.addChild(txt);

			var token:String = "GETUGkPFNC84JlzXkOMSYQFTOCAixOIiroh7oUj3k";
			var secret:String = "skitsanos";

			//Security.loadPolicyFile('https://vzaar.com/crossdomain.xml');
			//Security.loadPolicyFile('xmlsocket://staging.vzaar.com:5229');

			var api:Vzaar = new Vzaar(token, secret);

			api.addEventListener(VzaarEvent.VZAAR_WHO_AM_I, function(vzaar_event:VzaarEvent):void
			{
				if (vzaar_event.result.vzaar_api.error)
				{
					txt.text = vzaar_event.result.vzaar_api.error.type;
				}
				else
				{
					txt.text = vzaar_event.result.vzaar_api.test.login;
				}
			});

			trace("Calling...");
			api.whoAmI();
		}

	}
}
